/* eslint valid-jsdoc: "off" */

"use strict";
// const errorConfig = require('./error.config');
const path = require("path");
/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = (appInfo) => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = (exports = {});

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + "cloud_nine";

  // add your middleware config here
  config.middleware = ["errorHandler"];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };
  config.mongoose = {
    client: {
      url: "mongodb://127.0.0.1/laiyuze",
      options: {
        useUnifiedTopology: true,
      },
    },
  };

  config.cors = {
    origin: "*", // 表示允许的源
    allowMethods: "GET,HEAD,PUT,POST,DELETE,PATCH", // 表示允许的http请求方式
  };

  config.security = {
    csrf: {
      enable: false,
    },
  };

  config.logger = {
    outputJSON: true,
  };
  config.logrotator = {
    filesRotateBySize: [
      path.join(appInfo.root, "logs", appInfo.name, "egg-web.log"),
    ],
    maxFileSize: 2 * 1024 * 1024 * 1024,
  };

  config.jwt = {
    secret: "cloud_nine", // 自定义 token 的加密条件字符串
  };

  config.alinode = {
    server: "wss://agentserver.node.aliyun.com:8080",
    appid: "85655",
    secret: "37285d8e83cb8950a47188c2fa0d4dd0defdb497",
    logdir: "/logs/on_cloud_nine",
    error_log: ["/logs/on_cloud_nine"],
    packages: ["package.json"],
  };

  config.oss = {
    client: {
      accessKeyId: "LTAIxbpZ9b4Ga1Ge",
      accessKeySecret: "928cPYuhvAIgRN7j4m0zbjkq7ynuoH",
      bucket: "laiyuze",
      endpoint: "oss-cn-hangzhou.aliyuncs.com",
    },
  };

  config.view = {
    defaultViewEngine: "nunjucks",
  };

  return {
    ...config,
    ...userConfig,
  };
};
